import java.util.Scanner;
import java.util.Random;

import javax.swing.JOptionPane;

public class Challenge7
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		Random randomNumberGenerator = new Random();
		Boolean correct = false;
		double ranNum1 = 0;
		double ranNum2 = 0;
		
		while(!correct)		
		{
			ranNum1 = randomNumberGenerator.nextInt(10000000) + 1;
			ranNum2 = randomNumberGenerator.nextInt(10000000) + 1;
			
			String answerStr = JOptionPane.showInputDialog(null, "What is " + ranNum1 + " + " + ranNum2 + " equal?");
			double answer = Double.parseDouble(answerStr);
			
			try
			{
				if (ranNum1 + ranNum2 == answer)
				{
					JOptionPane.showMessageDialog(null, "CORRECT!");
				}
				else if (ranNum1 + ranNum2 != answer)
				{
					JOptionPane.showMessageDialog(null, "WRONG!");
				}
			}
			catch(Exception e)
			{
				correct = true;
				JOptionPane.showMessageDialog(null, "That was NOT a number!");		
			}
		}
	}
	
}
